package cjyyp.nio网络编程;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

@Slf4j
public class 单线程阻塞式客户端 {
    public static void main(String[] args) throws IOException {
        SocketChannel socketChannel=SocketChannel.open();
        socketChannel.connect(new InetSocketAddress("127.0.0.1",8080));//建立连接
        int write = socketChannel.write(StandardCharsets.UTF_8.encode("cjyyp"));//往通道写数据
        log.info("{}",write);
    }
}
